<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>JavaScriptLearn</title>
	<script type="text/javascript">
		/* 弹窗口脚本 */
		function moveon(){
			var answer=confirm("are you ready?");
			if(answer)
				window.location="http://www.imooc.com"
		}
		function debug(msg){
			confirm(msg);
		}
		function doo(){
			debug("this is doo call debug()");
		}
		var attime,flg;
		/* 开始计时setInterval() 在执行时,从载入页面后每隔指定的时间执行代码。*/
		function start(){
			var time = new Date();
			attime= time.getHours()+":"+time.getMinutes()+":"+time.getSeconds()+" 星期："+(time.getDay()) ;
			document.getElementById("clock").value = attime;
			
		}
		flg = setInterval("start()",1000);
		function stop(){
			flg = clearInterval(flg);
			
		}
		/* setTimeout("执行代码"，时间)计时器，在载入后延迟指定时间后,去执行一次表达式,仅执行一次。 */
		var flgCount,countNum=0;
		function countStart(){
			document.getElementById("countText").value = countNum++;
			flgCount = setTimeout("countStart()",1000);
			//confirm("123?");
		}
		function countStop(){
		 
			clearTimeout(flgCount);
		}
		
		/* History的特点 */
		function doHistory(){
			
			document.getElementById("historyText").value = window.history.length;
			//window.history.back();
			window.history.forward();
			//confirm("succeed");
		}
	
		/* 返回主页倒计时 */
		var i=5;
		function jsCount(){
			i--;
			//
			//document.getElementById("historyText").value = i;
			
			//confirm(i);
			document.getElementById("djs").innerHTML = i;
			setTimeout("jsCount()",1000);
		}
		jsCount();
		
		function ch(){
		//document.getElementById("djs").innerHTML = i;
		}
		
		
		function back(){
			history.go(-1);
		}
	</script>
</head>
<body>
<h1>按钮点击事件</h1>
<button onclick="moveon()">Check</button>
<button onclick="doo()">debug</button>
<input type="button" onclick="doo()" value="doo"/><br/>
<input type="button" onclick="start()" value="start"/>
<input type="button" onclick="stop()" value="stop"/>
<input type="text" id="clock" size="50"/><br/>
<input type="button" onclick="countStart()" value="countStart"/>
<input type="button" onclick="countStop()" value="countStop"/>
<input type="text" id="countText" size="50"/><br/>
<a name="target1" href="#target1">第1个锚点</a>
<a name="target2" href="#target2">第2个锚点</a>
<input type="button" onclick="doHistory()" value="doHistory"/>
<input type="text" id="historyText" size="50"/><br/>
<span id="djs">5</span>秒后返回主页。<a href="javascript:back()">返回</a>
<input type="button" value="test" onclick="ch()"/>
</body>
</html>